import React, {Component} from "react";

export default class SecondComponent extends Component {
    constructor() {
        super();
        this.state={
            innerWidth: window.innerWidth
        }
    }
    componentDidMount() {
        window.addEventListener('resize', this.handleResize.bind(this));
    }
    componentWillUnmount() {
        window.removeEventListener('resize', this.handleResize.bind(this))
    }
    handleResize() {
        this.setState({
            innerWidth: window.innerWidth,
        })
    }
    render() {
        console.log(this.state.innerWidth);
        return (
            <div className="" style={{fontSize:this.state.innerWidth/800*28}}>
                第二个组件
            </div>
        );
    }
}
